package cn.schoolwow.quickdao.test.module.initial.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import com.zaxxer.hikari.HikariDataSource;

public class SetPostgresDataSourceFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        HikariDataSource hikariDataSource = new HikariDataSource();
        hikariDataSource.setDriverClassName("org.postgresql.Driver");
        hikariDataSource.setJdbcUrl("jdbc:postgresql://127.0.0.1:5432/quickDAO?stringtype=unspecified&useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true");
        hikariDataSource.setUsername("postgres");
        hikariDataSource.setPassword("123456");

        flowContext.putTemporaryData("hikariDataSource", hikariDataSource);
    }

    @Override
    public String name() {
        return "设置Postgres数据库源";
    }
}
